package com.hbx.platform.base.service.impl;

import com.hbx.platform.base.mapper.BaseMapper;
import com.hbx.platform.base.query.BaseQuery;
import com.hbx.platform.base.service.IBaseService;
import com.hbx.platform.base.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author: hbx
 * @date: 2024/04/06
 **/
public class BaseServiceImpl<T> implements IBaseService<T> {

    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public List<T> getAll() {
        return baseMapper.getAll();
    }

    @Override
    public T queryById(Long id) {
        return baseMapper.queryById(id);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public void save(T t) {
//        employee.setHeadImage("https://q7.itc.cn/q_70/images03/20240326/06af1584099a4f4496b69a1f0057f86a.jpeg");
        baseMapper.save(t);
    }

    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }

    @Override
    public PageList page(BaseQuery query) {
        List<T> list = baseMapper.page(query);
        Integer count = baseMapper.getCount(query);
        return new PageList(count, list);
    }

    @Override
    public Integer batchDelete(List<Long> ids) {
        return baseMapper.batchDelete(ids);
    }
}
